package model

type StockUser struct {
	Id              int32      `gorm:"column:id;primary_key;AUTO_INCREMENT;NOT NULL" example:"1" json:"id,omitempty"`
	CustomerId      string     `gorm:"column:customer_id;NOT NULL;comment:'用户ID'" example:"sdadjsgkhyhsd5745ad4adsa44" json:"customerId,omitempty"`
	CustomerName    string     `gorm:"column:customer_name;NOT NULL;comment:'用户名'" example:"zhangyu" json:"customerName,omitempty"`
	MobileNo        string     `gorm:"column:mobile_no;comment:'手机号'"    example:"18739473138" json:"mobileNo,omitempty"`
	Email           string     `gorm:"column:email;comment:'邮箱'" example:"2470838639@qq.com" json:"email,omitempty"`
	Status          string     `gorm:"column:status;default:Y;NOT NULL;comment:'用户状态：Y/N '" example:"Y" json:"status,omitempty"`
	LoginPassword   string     `gorm:"column:login_password;NOT NULL;comment:'密码'" example:"asas5743a25dssf4d3a54dsa53" json:"loginPassword,omitempty"`
	LoginRandomSalt string     `gorm:"column:login_random_salt" json:"loginRandomSalt,omitempty"`
	RegisterDate    *LocalTime `gorm:"column:register_date;default:CURRENT_TIMESTAMP;NOT NULL;comment:'注册时间'" example:"2021-05-26 08:25" json:"registerDate,omitempty"`
	RegisterChannel string     `gorm:"column:register_channel;comment:'注册渠道 PC/APP'" example:"APP" json:"registerChannel,omitempty"`
	PwdStatus       string     `gorm:"column:pwd_status;comment:'密码是否自动生成：Y 是，N 否'" example:"N" json:"pwdStatus,omitempty"`
	UserLeveMark    string     `gorm:"column:user_leve_mark;default:'general';comment:'账户类型'" json:"userLeveMark,omitempty"`
	LoginDate       *LocalTime `gorm:"column:login_date;comment:'最后一次登录时间'" example:"2021-05-26 08:25" json:"loginDate,omitempty"`
	CreateTime      *LocalTime `gorm:"column:create_time;default:CURRENT_TIMESTAMP;NOT NULL" example:"2021-05-26 08:25" json:"createTime,omitempty"`
	LastUpdTime     *LocalTime ` gorm:"column:last_upd_time;default:CURRENT_TIMESTAMP;NOT NULL" example:"2021-05-26 08:25" json:"lastUpdTime,omitempty"`
}

func NewStockUserModel() *StockUser {
	return &StockUser{}
}

// mysql 时间内和go 时间类型转换
/* mysql【timestamp】 ---> Go【time.Time】 时间类型的转换
问题：	 sql: Scan error on column index 6: unsupported Scan, storing driver.Value type []uint8 into type *time.Time
原因：	驱动读取timestamp类型的数据时, 直接读取为int8的格式, 然后在尝试赋值到time.Time的时候出错
解决：	在配置文件mysql连接上添加参数：	parseTime=true
*/

func (s *StockUser) TableName() string {
	return "stock_user"
}
